From 8249f225d0e26dd1b9c4345f50f31b7f82c9b72f Mon Sep 17 00:00:00 2001 From: Tom Gilder Date: Tue, 18 Jan 2005 03:06:20 +0000 Subject: [PATCH] Much more graceful way of not showing logged-in pages to logged-out users --- includes/OutputPage.php | 2 +- includes/User.php | 29 +++++++++-------------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 2903e0dbce..60ce7dd22f 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -112,7 +112,7 @@ class OutputPage { $ismodsince = wfTimestamp( TS_MW, strtotime( $modsince ) ); wfDebug( "-- client send If-Modified-Since: " . $modsince . "\n", false ); wfDebug( "-- we might send Last-Modified : $lastmod\n", false ); - if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) && !$wgUser->wasLoggedInAt( $ismodsince )) { + if( ($ismodsince >= $timestamp ) && $wgUser->validateCache( $ismodsince ) ) { # Make sure you're in a place you can leave when you call us! header( "HTTP/1.0 304 Not Modified" ); $this->mLastModified = $lastmod; diff --git a/includes/User.php b/includes/User.php index c347f3030e..036d8837ea 100644 --- a/includes/User.php +++ b/includes/User.php @@ -153,7 +153,7 @@ class User { $fname = 'User::loadDefaults' . $n; wfProfileIn( $fname ); - global $wgContLang, $wgIP; + global $wgContLang, $wgIP, $wgDBname; global $wgNamespacesToBeSearchedDefault; $this->mId = 0; @@ -175,9 +175,16 @@ class User { unset( $this->mSkin ); $this->mDataLoaded = false; $this->mBlockedby = -1; # Unset - $this->mTouched = '0'; # Allow any pages to be cached $this->setToken(); # Random $this->mHash = false; + + if ( isset( $_COOKIE[$wgDBname.'LoggedOut'] ) ) { + $this->mTouched = wfTimestamp( TS_MW, $_COOKIE[$wgDBname.'LoggedOut'] ); + } + else { + $this->mTouched = '0'; # Allow any pages to be cached + } + wfProfileOut( $fname ); } @@ -899,10 +906,6 @@ class User { } else { setcookie( $wgDBname.'Token', '', time() - 3600 ); } - - # Clear previous logged out time, set logged in time - setcookie( $wgDBname.'LoggedOut', '', time() - 3600, $wgCookiePath, $wgCookieDomain ); - setcookie( $wgDBname.'LoggedIn', wfTimestampNow(), time() + 86400, $wgCookiePath, $wgCookieDomain ); } /** @@ -1184,20 +1187,6 @@ class User { } return false; } - - /** - * Check if the user was logged on at a certain timestamp, but no longer is. - * @param int $timestamp Timestamp to check. - * @return bool True if user was logged in. - */ - function wasLoggedInAt( $timestamp ) { - global $wgDBname; - - if ( !$this->getID() && isset( $_COOKIE[$wgDBname.'LoggedIn'] ) && isset( $_COOKIE[$wgDBname.'LoggedOut'] ) ) - return ( $timestamp >= $_COOKIE[$wgDBname.'LoggedIn'] && $timestamp <= $_COOKIE[$wgDBname.'LoggedOut'] ); - else - return false; - } } ?> -- 2.20.1